package cn.yx.user.controller.api.handler;

import cn.yx.common.core.enums.SentinelExceptionEnum;
import cn.yx.common.core.pojo.ResponseVo;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import lombok.extern.slf4j.Slf4j;

/**
 * <p>用户账户API流控处理类</p>
 *
 * @author Wgssmart
 */
@Slf4j
public class UserAccountSentinelHandler {

    public static ResponseVo<String> getByIdBlockHandler(Long id, BlockException blockException) {
        log.error("getByIdBlockHandler: {}", blockException.getMessage());
        log.error("getByIdBlockHandler", blockException);
        return ResponseVo.serviceError(SentinelExceptionEnum.FLOW_EXCEPTION.getMessage());
    }

    public static ResponseVo<String> getByIdFallback(Long id, Throwable throwable) {
        log.error("getByIdFallback: {}", throwable.getMessage());
        log.error("getByIdFallback", throwable);
        return ResponseVo.serviceError(SentinelExceptionEnum.DEGRADE_EXCEPTION.getMessage());
    }

}
